<template>
	<m-cpage :list="formList"  @submit="submit" @extendFunc="extendFunc"></m-cpage>
</template>

<script>
	export default {
		name:'forgetPwd',
		data() {
			let _this = this;
			return {
				formList:[
					{
						label:'请输入新密码',
						placeholder:'6-10位，由数字+字母组成',
						tag:'password',
						type:'password',
						icon:'eyes',
						rules:{
							type: 'string',
							required: true,
							message: '6-10位，由数字+字母组成',
							trigger: ['blur', 'change'],
							validator:(rule,value,callback) => {
								return _this.utils.CheckPassWord(value)
							}
						},
					},
					{
						label:'确认新密码',
						placeholder:'6-10位，由数字+字母组成',
						tag:'password2',
						type:'password',
						icon:'eyes',
						rules:{
							type: 'string',
							required: true,
							message: '6-10位，由数字+字母组成',
							trigger: ['blur', 'change'],
							validator:(rule,value,callback) => {
								return CheckPassWord(value)
							}
						},
					},
					{
						button:true,
						disabled:false,
						submit:true,
						func:'submit',
						type:'',
						btn:'确认修改',
						btnStyle:{
							color:'#fff',fontSize:'14px',
							background:'#16b7ff',borderRadius:'5rpx',
						},
						classes:'noBorder pt50'
					},{
						button:true,
						disabled:false,
						func:'extendFunc',
						type:'text',
						login:true,
						btn:'返回',
						classes:'noBorder pb70',
						btnStyle:{
							color:'#26bbff',fontSize:'14px'
						},
					}
				],
				options:{}
			};
		},
		onLoad(options) {
			this.options = options
		},
		methods:{
			extendFunc(item){
				if(this.options.setting){
					this.utils.goPath('/pages/setting/setting',{},'redirectTo')
				}else{
					this.utils.goPath('/pages/login/login',{type:1},'redirectTo')
				}
			},
			submit(val){
				let par = {
					...val,
					...this.options
				}
				let cmd = 'reset_pwd_email'
				if(par.phone){
					cmd = 'reset_pwd_phone'
				}
				par.pass_word = par.password;
				this.$api[cmd](par).then(res => {
					if(res.code == 200){
						this.utils.goPath('/pages/success/success',{type:1,setting:this.options.setting?1:''},'redirectTo')
					}else{
						uni.showToast({
							title:res.message,
							icon:'none'
						})
					}
				})
				
				
			},
		}
	}
</script>

<style lang="scss">

</style>
